home *** CD-ROM | disk | FTP | other *** search
- Path: qualcomm.com!usenet
- From: nababs@qualcomm.com (Nasser Abbasi)
- Newsgroups: comp.lang.c++
- Subject: Re: I need some help using the do/while loop
- Date: 15 Feb 1996 21:38:27 GMT
- Organization: Qualcomm Inc.
- Message-ID: <4g094j$pih@qualcomm.com>
- References: <4fp3nc$bh8@ixnews7.ix.netcom.com> <4fpg9j$dsj@qualcomm.com> <DMtn4A.I7M@udcf.gla.ac.uk>
- NNTP-Posting-Host: nabbasi.qualcomm.com
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.14
-
- In article <DMtn4A.I7M@udcf.gla.ac.uk>, dpirie@aero.gla.ac.uk says...
-
-
- >
- >>
- >> IF Number_Of_Interations Greater than 0 THEN
- >**********************************************************************
- >> Miles_Per_Gallon := Total_Miles_Per_Gallon / Number_Of-Iterations
- >**********************************************************************
- >> Output "The overall average miles/gallon was " Miles_Per_Gallon
- >> ELSE
- >> Output "No data supplied for program"
- >> END IF
- >>
-
-
- >.........
- >The step which I've enclosed in rows of ******** is quite wrong.
- >The total miles/gallon = totalMiles/totalGallons.
- > =
- (M1+M2+...+Mn)/(G1+G2+...+Gn)
- >This does NOT = (M1/G1 + M2/G2 + ... +Mn/Gn)/n, as implied in Nasser's
- pseudocode above.
- >
- >David Pirie
- >
- >
-
-
- Thanks for reviewing the code. BUT, I was following the customer
- requirments :) , the original poster said to find
-
- "The overall average miles/gallon "
-
- I read this to mean to find the miles/gallon for each iteration, then
- take the average of that, (since he asked for AVERAGE, and the average
- of a QUANTITY is the sum of the QUANITIES divided by
- Number_Of_Interations, which is what I did).
-
- If the original post said to "The overall miles/gallon " then you are
- correct offcourse but that is not what he asked for (even though that is
- what it looks like he wanted actually, from looking at the sample numbers
- in the original post).
-
- So, I think I was following the requirments correctly, but it seems
- requirments are not correct.
-
- this is a good example that one must make sure the requirments are clear
- and to know what the customer wants before starting to code against them
- :)
-
- Nasser
-
-